package cmpe273.classproject.testclient;

import java.util.Random;

import cmpe273.classproject.server.service.MovieServiceImplProxy;

public class MyThread implements Runnable {

	String name;
	static Long lExecutionTime = new Long(0);
	Thread t;
	private MovieServiceImplProxy service;

	public MyThread(String name) {
		this.name = name;
		t = new Thread(this, name);
		t.start();
		service = new MovieServiceImplProxy();
	}

	@Override
	public void run() {
		try {
			long startTime = System.currentTimeMillis();
			Random rand = new Random(50+20);
			TestMovie tm = new TestMovie(rand.nextInt(), service);
			long endTime = System.currentTimeMillis();

			synchronized (lExecutionTime) {
				lExecutionTime += ((endTime - startTime) / 5);
				// lExecutionTime++;
//				System.out.println("Thread: "
//						+ Thread.currentThread().getName() + " "
//						+ lExecutionTime.toString());
			}

			// Thread.currentThread().join();
		} catch (Exception ex) {
			ex.printStackTrace();
		}

	}
}
